//封装高阶组件
//核心逻辑：有token正常跳转无token去登录

import {getToken} from '@/utils'
import  {Navigate} from 'react-router-dom'

const AutoRouter=({children})=>{
    const token = getToken()
    if (token){
        return <>{children}</>
    }else{
        // 重定向到登录页面  //replace代表替换原则
        return <Navigate  to ={'/login'} replace/>
    }
}

export {AutoRouter} 